/**
 * Copyright (c) 2025 情感机器（北京）科技有限公司
 * LLMOne is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *          http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */

import * as React from 'react'
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group'

import { cn } from '@/lib/utils'

export function CardSelectGroup({ className, ...props }: React.ComponentProps<typeof RadioGroupPrimitive.Root>) {
  return <RadioGroupPrimitive.Root className={cn('grid grid-cols-2 gap-3', className)} {...props} />
}

export function CardSelectItem({ className, ...props }: React.ComponentProps<typeof RadioGroupPrimitive.Item>) {
  return (
    <RadioGroupPrimitive.Item
      className={cn(
        'group relative flex flex-col items-start overflow-hidden rounded-lg border bg-card p-5 text-left transition-colors disabled:pointer-events-none aria-checked:border-primary aria-checked:bg-primary/5 disabled-all:opacity-50 disabled-all:grayscale-100 not-disabled-all:pointer-events-auto hover-enabled:border-accent-foreground/25 hover-enabled:bg-accent',
        'outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50',
        className,
      )}
      {...props}
    />
  )
}

export function CardSelectIndicator({
  className,
  ...props
}: React.ComponentProps<typeof RadioGroupPrimitive.Indicator>) {
  return (
    <RadioGroupPrimitive.Indicator
      className={cn('absolute -top-4 -left-4 size-7 rotate-45 bg-primary', className)}
      {...props}
    />
  )
}
